﻿/*************************************************************************
 * 
 * Filename :config
 * 
 * steven hu   2010/3/8 15:45:54
 *  
 * http://www.cnblogs.com/huxj
 *   
 * 
 * Change History:
 * 
 * 
**************************************************************************/



using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hxj.Web;
using System.IO;

namespace RicciWebsite.admin
{
    public partial class config : RicciWebsite.Pages.AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RicciWebsite.config configInfo = configHelper.Get();
                txtCopyright.Text = configInfo.Copyright;
                txtEmail.Text = configInfo.Email;
                txtFax.Text = configInfo.Fax;
                txtMsn.Text = configInfo.Msn;
                txtMsnUrl.Text = configInfo.Msnurl;
                txtPhone.Text = configInfo.Phone;
                txtWebsitename.Text = configInfo.Websitename;
                //imglogo.ImageUrl = configInfo.Logo;
            }
        }


        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
 //           Hxj.Web.UploadFile upload = new Hxj.Web.UploadFile();
 //           upload.AddAllowFileExtension("jpg", "gif", "jpeg");
 //           upload.FilePath = "~/upload/uploadfiles/templogo";
 //           upload.Rename = "logo";
 //           UploadFileInfo fileinfo = upload.Upload(Request.Files["filelogo"]);

 //           System.Drawing.Image img = System.Drawing.Image.FromFile(fileinfo.FullPath);
 //           if (img.Height < 72)
 //           {
 //               File.Delete(fileinfo.FullPath);
 //               JavaScript.MsgBox("LOGO的高度为72px!");
 //               return;
 //           }
 //           else if (img.Height > 72)
 //           {
 //Hxj.Common.
 //           }


            RicciWebsite.config configInfo = new RicciWebsite.config();

            configInfo.Copyright = txtCopyright.Text;
            configInfo.Email = txtEmail.Text;
            configInfo.Fax = txtFax.Text;
            configInfo.Msn = txtMsn.Text;
            configInfo.Msnurl = txtMsnUrl.Text;
            configInfo.Phone = txtPhone.Text;
            configInfo.Websitename = txtWebsitename.Text;
            //configInfo.Logo = fileinfo.Path;
            configHelper.Set(configInfo);
            //imglogo.ImageUrl = configInfo.Logo;
            Hxj.Web.JavaScript.MsgBox("修改成功!");

        }
    }
}
